package com.sachin.coherence;

import com.tangosol.net.CacheFactory;

public class CoherenceSwitch implements Runnable {

	private CoherenceBootup coherenceBootup = new CoherenceBootup();
	private static boolean running  = true;
	@Override
	public void run() {
		System.setProperty("tangosol.coherence.override",
		"sachin-tangosol-coherence.xml");
		if(CacheFactory.getCluster().isRunning()) {
			coherenceBootup.shutdown();
			running = false;
		} else {
			coherenceBootup.start();
			while(running) {
				try {
					Thread.sleep(Long.MAX_VALUE);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}

	}

}
